// +------------------------------------------------------------+
// |                       Popup Calendar                       |
// +------------------------------------------------------------+
// | Last Modified:                  27-Jan-2003                |
// | Web Site:                       http://www.yxScripts.com   |
// | EMail:                          m_yangxin@hotmail.com      |
// +------------------------------------------------------------+
// |      Copyright 2003  Xin Yang    All Rights Reserved.      |
// +------------------------------------------------------------+

// default settings
var yxConf=["yyyy/mm/dd", 0, 1, 1, 1, "verdana", 12, 120, 1, 18, 1];
var yxColors=["#cccccc", "#000000", "#999999", "#ffffff", "#ffffff", "#000000", "#999999", "#ffffff", "#ffffff", "#999999", "#ffffff", "#cccccc", "#000000", "#000000"]
var yxMonths=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var yxDays=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
var yxLinks=["[Clear]", "[Close]"];
var yxTags=["&#171;", "&#187;", "&#139;", "&#155;"];
// ------

// codes
var yxCal="yxCal";
var yxCals=new Array();
var yxCurCal=null;
var yxCY, yxCM, yxMX=0, yxMY=0;

var yxTL=" style='text-decoration:none; background-color:transparent'>";
var yxTable="<table cellpadding='0' cellspacing='0' border='0'>";

var yxIsOpera=(navigator.userAgent.indexOf("Opera")!=-1);
var yxIsIE=(navigator.userAgent.indexOf("MSIE")!=-1 && !yxIsOpera);
var yxIsIE4=(navigator.appVersion.indexOf("MSIE 4")!=-1);
var yxIsIE5=(yxIsIE && !yxIsIE4);
var yxIsN6=(navigator.userAgent.indexOf("Gecko")!=-1);
var yxIsN4=(typeof(document.layers)!="undefined");
var yxIsMac=(navigator.userAgent.indexOf("Mac")!=-1);
var yxIsKon=(navigator.userAgent.indexOf("Konqueror")!=-1);
var yxIsK3=(yxIsKon && navigator.appVersion.indexOf('Konqueror/3')!=-1);
var yxIsO7=(navigator.userAgent.indexOf("Opera 7")!=-1);
var yxCalSafe=(yxIsN6 || yxIsN4 || yxIsIE5 || yxIsIE4 && !yxIsMac || yxIsK3 || yxIsO7);

var yxLayers=null;
if (yxIsIE) {
  yxLayers=document.all;
}
else if (yxIsN4) {
  yxLayers=document.layers;
  yxConf[6]+=2;
}
else if (yxIsN6 || yxIsK3 || yxIsO7) {
  yxLayers=yxDOM;
}

if (yxIsIE && yxIsMac) { yxConf[9]+=4; }

function yxDOM(id) { return document.getElementById(id); }

function yxSpan(color,content) {
  return "<span style='font-family:"+yxConf[5]+"; font-size:"+yxConf[6]+"px; color:"+color+";'>"+content+"</span>";
}

function yxCalOBJ(name, field, form, date, id, id2, dx, dy) {
  this.name=name;
  this.field=field; this.formName=form; this.form=null;
  this.date=date;
  this.id=id; this.id2=id2;
  this.dx=dx; this.dy=dy;
  this.Sun=1; this.work=1; this.Sat=1;
  this.range=null; this.rangeOn=new Array(); this.rangeOff=new Array(); this.datesOn=""; this.datesOff="";
}

function yxFindCal(name) {
  for (var i=0; i<yxCals.length; i++) {
    if (yxCals[i].name==name) {
      if (yxCals[i].form==null) {
        if (yxCals[i].formName=="") {
          if (document.forms[0]) {
            yxCals[i].form=document.forms[0];
          }
        }
        else if (document.forms[yxCals[i].formName]) {
          yxCals[i].form=document.forms[yxCals[i].formName];
        }
      }

      return yxCals[i];
    }
  }

  return null;
}

function yxDayName(y,m,d) {
  return yxDays[(new Date(y,m,d)).getDay()].substring(0,3);
}

function yxMonthFromName(m3) {
  for (var i=0; i<yxMonths.length; i++) {
    if (yxMonths[i].toLowerCase().substring(0,3)==m3.toLowerCase()) {
      return i;
    }
  }
  return 0;
}

function yxFormat() {
  var calF=yxConf[0];

  calF=calF.replace(/\\/g, '\\\\');
  calF=calF.replace(/\//g, '\\\/');
  calF=calF.replace(/\[/g, '\\\[');
  calF=calF.replace(/\]/g, '\\\]');
  calF=calF.replace(/\(/g, '\\\(');
  calF=calF.replace(/\)/g, '\\\)');
  calF=calF.replace(/\{/g, '\\\{');
  calF=calF.replace(/\}/g, '\\\}');
  calF=calF.replace(/\</g, '\\\<');
  calF=calF.replace(/\>/g, '\\\>');
  calF=calF.replace(/\|/g, '\\\|');
  calF=calF.replace(/\*/g, '\\\*');
  calF=calF.replace(/\?/g, '\\\?');
  calF=calF.replace(/\+/g, '\\\+');
  calF=calF.replace(/\^/g, '\\\^');
  calF=calF.replace(/\$/g, '\\\$');

  calF=calF.replace(/dd/i, '\\d\\d');
  calF=calF.replace(/mm/i, '\\d\\d');
  calF=calF.replace(/yyyy/i, '\\d\\d\\d\\d');
  calF=calF.replace(/day/i, '\\w\\w\\w');
  calF=calF.replace(/mon/i, '\\w\\w\\w');

  return new RegExp(calF);
}

function yxDateNumbers(date) {
  var y, m, d;

  var yIdx=yxConf[0].search(/yyyy/i);
  var mIdx=yxConf[0].search(/mm/i);
  var m3Idx=yxConf[0].search(/mon/i);
  var dIdx=yxConf[0].search(/dd/i);

  y=date.substring(yIdx,yIdx+4)-0;
  if (mIdx!=-1) {
    m=date.substring(mIdx,mIdx+2)-1;
  }
  else {
    var m=yxMonthFromName(date.substring(m3Idx,m3Idx+3));
  }
  d=date.substring(dIdx,dIdx+2)-0;

  return new Array(y,m,d);
}

function yxHideCal() {
  if (yxConf[4]==1) {
    if (yxIsIE) {
      yxLayers[yxCal].style.visibility="hidden";
    }
    else if (yxIsN4) {
      yxLayers[yxCal].visibility="hide";
      yxLayers[yxCal].document.open();
      yxLayers[yxCal].document.close();
    }
    else {
      yxLayers(yxCal).style.visibility="hidden";
    }
  }

  window.status="";
}

function yxLeft(l) { return l.offsetLeft+(l.offsetParent?yxLeft(l.offsetParent):(yxIsIE && yxIsMac)?parseInt(document.body.leftMargin):0); }
function yxTop(l) { return l.offsetTop+(l.offsetParent?yxTop(l.offsetParent):(yxIsIE && yxIsMac)?parseInt(document.body.topMargin):0); }
function yxLeftN4(l) { return l.pageX; }
function yxTopN4(l) { return l.pageY; }

function yxLastDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  for (var i=31; i>=28; i--) {
    var nd=new Date(yy,mm,i);
    if (mm==nd.getMonth()) {
      return i;
    }
  }
  return 31;
}

function yxFirstDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  var fd=new Date(yy,mm,1);
  return fd.getDay();
}

function yxDayDisplay(i) {
  if (yxConf[10]==0) {
    return yxDays[i];
  }
  else {
    return yxDays[i].substring(0,yxConf[10]);
  }
}

function yxCalTitle(d) {
  var yy=d.getFullYear(), mm=yxMonths[d.getMonth()];
  var s;

  if (yxConf[8]==2) {
    s="<tr bgcolor='"+yxColors[0]+"'><td colspan='7' align='center'>"+yxTable+"<tr align='center' valign='middle'>"+(yxConf[2]==1?("<td><a href='javascript:yxMoveYear(-10)'"+yxTL+yxSpan(yxColors[1],yxTags[0])+"</a></td><td>"+yxSpan(yxColors[1],"&nbsp;")+"</td><td><a href='javascript:yxMoveYear(-1)'"+yxTL+yxSpan(yxColors[1],yxTags[2])+"</a></td>"):"")+"<td width='"+yxConf[7]+"'>"+yxSpan(yxColors[1],yy)+"</td>"+(yxConf[2]==1?("<td><a href='javascript:yxMoveYear(1)'"+yxTL+yxSpan(yxColors[1],yxTags[3])+"</a></td><td>"+yxSpan(yxColors[1],"&nbsp;")+"</td><td><a href='javascript:yxMoveYear(10)'"+yxTL+yxSpan(yxColors[1],yxTags[1])+"</a></td>"):"")+"</tr><tr align='center' valign='middle'>"+(yxConf[2]==1?("<td align='right' colspan='3'><a href='javascript:yxMoveMonth(-1)'"+yxTL+yxSpan(yxColors[1],yxTags[2])+"</a></td>"):"")+"<td width='"+yxConf[7]+"'>"+yxSpan(yxColors[1],mm)+"</td>"+(yxConf[2]==1?("<td align='left' colspan='3'><a href='javascript:yxMoveMonth(1)'"+yxTL+yxSpan(yxColors[1],yxTags[3])+"</a></td>"):"")+"</tr></table></td></tr><tr align='center' bgcolor='"+yxColors[2]+"'>";
  }
  else {
    s="<tr bgcolor='"+yxColors[0]+"'><td colspan='7' align='center'>"+yxTable+"<tr align='center' valign='middle'>"+(yxConf[2]==1?("<td><a href='javascript:yxMoveYear(-1)'"+yxTL+yxSpan(yxColors[1],yxTags[0])+"</a></td><td>"+yxSpan(yxColors[1],"&nbsp;")+"</td><td><a href='javascript:yxMoveMonth(-1)'"+yxTL+yxSpan(yxColors[1],yxTags[2])+"</a></td>"):"")+"<td width='"+yxConf[7]+"'><nobr>"+yxSpan(yxColors[1],mm+" "+yy)+"</nobr></td>"+(yxConf[2]==1?("<td><a href='javascript:yxMoveMonth(1)'"+yxTL+yxSpan(yxColors[1],yxTags[3])+"</a></td><td>"+yxSpan(yxColors[1],"&nbsp;")+"</td><td><a href='javascript:yxMoveYear(1)'"+yxTL+yxSpan(yxColors[1],yxTags[1])+"</a></td>"):"")+"</tr></table></td></tr><tr align='center' bgcolor='"+yxColors[2]+"'>";
  }

  for (var i=yxConf[1]; i<yxConf[1]+7; i++) {
    s+="<td width='"+yxConf[9]+"'>"+yxSpan(yxColors[3],yxDayDisplay(i))+"</td>";
  }

  s+="</tr>";

  return s;
}

function yxCalHeader() {
  return "<table bgcolor='"+yxColors[13]+"' cellspacing='0' cellpadding='1'><tr><td><table cellspacing='1' cellpadding='3' border='0'>";
}

function yxCalFooter() {
  return (yxConf[3]==1?("<tr bgcolor='"+yxColors[11]+"'><td colspan='7' align='center'>"+yxTable+"<tr><td><a href='javascript:yxClearDate()'"+yxTL+yxSpan(yxColors[12],yxLinks[0])+"</a></td><td>"+yxSpan(yxColors[12],"&nbsp;&nbsp;")+"</td><td><a href='javascript:yxHideCal()'"+yxTL+yxSpan(yxColors[12],yxLinks[1])+"</a></td></tr></table></td></tr>"):"")+"</table></td></tr></table>";
}

function yxCalBody(d,day) {
  var s="", dc=1, fd=yxFirstDay(d), ld=yxLastDay(d);
  var yy=d.getFullYear(), mm=d.getMonth();
  var dateOff, wd, nd;

  if (yxConf[1]>0 && fd==0) { fd=7; }

  for (var i=0; i<6; i++) {
    s+="<tr align='center' bgcolor='"+yxColors[10]+"'>";
    for (var j=yxConf[1]; j<yxConf[1]+7; j++) {
      if (i*7+j<fd || dc>ld) {
        s+="<td>"+yxSpan(yxColors[10],"&nbsp;")+"</td>";
      }
      else {
        nd=new Date(yy,mm,dc); wd=nd.getDay(); dstr=yxGetDate(nd); dateOff=false;
        dateOff=false;

        if (yxCurCal.Sun==0 && wd==0 || yxCurCal.Sat==0 && wd==6 || yxCurCal.work==0 && wd!=0 && wd!=6) {
          dateOff=true;
        }
        if (dateOff) {
          for (var ii=0; ii<yxCurCal.rangeOn.length; ii++) {
            if (compareDates(yxCurCal.rangeOn[ii][0],dstr)<=0 && compareDates(dstr,yxCurCal.rangeOn[ii][1])<=0) {
              dateOff=false; break;
            }
          }
        }
        if (!dateOff) {
          for (var ii=0; ii<yxCurCal.rangeOff.length; ii++) {
            if (compareDates(yxCurCal.rangeOff[ii][0],dstr)<=0 && compareDates(dstr,yxCurCal.rangeOff[ii][1])<=0) {
              dateOff=true;
            }
          }
        }
        if (yxCurCal.datesOn.indexOf(dstr)!=-1) {
          dateOff=false;
        }
        if (yxCurCal.datesOff.indexOf(dstr)!=-1) {
          dateOff=true;
        }
        if (!dateOff && yxCurCal.range!=null) {
          if (compareDates(yxCurCal.range[0],dstr)>0 || compareDates(dstr,yxCurCal.range[1])>0) {
            dateOff=true;
          }
        }

        if (dateOff) {
          s+="<td bgcolor='"+yxColors[8]+"'>"+yxSpan(yxColors[9],dc++)+"</td>";
        }
        else {
          var bgColor=(dc==day)?yxColors[6]:yxColors[4];
          var fgColor=(dc==day)?yxColors[7]:yxColors[5];

          s+="<td bgcolor='"+bgColor+"'><a href='javascript:yxPickDate("+dc+")'"+yxTL+yxSpan(fgColor,dc++)+"</a></td>";
        }
      }
    }
    s+="</tr>";
  }

  return s;
}

function yxCheckRange(dir) {
  var fd=new Date(yxCY,yxCM,1);
  if (dir<0) {
    fd=new Date(yxCY,yxCM,yxLastDay(fd));
    if (compareDates(yxGetDate(fd),yxCurCal.range[0])<0) {
      var lr=yxDateNumbers(yxCurCal.range[0]);
      yxCY=lr[0]; yxCM=lr[1];
    }
  }
  else {
    if (compareDates(yxGetDate(fd),yxCurCal.range[1])>0) {
      var lr=yxDateNumbers(yxCurCal.range[1]);
      yxCY=lr[0]; yxCM=lr[1];
    }
  }
}

function yxMoveYear(dy) {
  yxCY+=dy;
  if (yxCurCal.range!=null) { yxCheckRange(dy); }

  yxChangeCal(new Date(yxCY,yxCM,1));
}

function yxMoveMonth(dm) {
  yxCM+=dm;
  if (yxCM<0) { yxCM=11; yxCY--; }
  if (yxCM>11) { yxCM=0; yxCY++;}
  if (yxCurCal.range!=null) { yxCheckRange(dm); }

  yxChangeCal(new Date(yxCY,yxCM,1));
}

function yxChangeCal(d) {
  var dd=0;

  if (yxCurCal!=null) {
    var calRE=yxFormat();

    if (yxCurCal.form[yxCurCal.field].value!="" && calRE.test(yxCurCal.form[yxCurCal.field].value) || yxCurCal.date!="" && calRE.test(yxCurCal.date)) {
      var cd=yxDateNumbers((yxCurCal.form[yxCurCal.field].value!="")?yxCurCal.form[yxCurCal.field].value:yxCurCal.date);
      if (cd[0]==d.getFullYear() && cd[1]==d.getMonth()) {
        dd=cd[2];
      }
    }
    else {
      var cd=new Date();
      if (cd.getFullYear()==d.getFullYear() && cd.getMonth()==d.getMonth() && yxConf[4]==1) {
        dd=cd.getDate();
      }
    }
  }

  var calendar=yxCalHeader()+yxCalTitle(d)+yxCalBody(d,dd)+yxCalFooter();

  if (yxIsIE) {
    yxLayers[yxCal].innerHTML=calendar;
  }
  else if (yxIsN4) {
    yxLayers[yxCal].document.open();
    yxLayers[yxCal].document.writeln(calendar);
    yxLayers[yxCal].document.close();
  }
  else {
    yxLayers(yxCal).innerHTML=calendar;
  }
}

function yxShowCal(name) {
  if (!yxCalSafe) { return; }

  var lastCal=yxCurCal;
  var d=new Date(), dd=0;

  yxCurCal=yxFindCal(name);

  if (yxCurCal!=null && yxCurCal.form!=null && yxCurCal.form[yxCurCal.field]) {
    var calRE=yxFormat();

    if (yxCurCal.form[yxCurCal.field].value!="" && calRE.test(yxCurCal.form[yxCurCal.field].value) || yxCurCal.date!="" && calRE.test(yxCurCal.date)) {
      var cd=yxDateNumbers((yxCurCal.form[yxCurCal.field].value!="")?yxCurCal.form[yxCurCal.field].value:yxCurCal.date);
      d=new Date(cd[0],cd[1],cd[2]);

      yxCY=cd[0];
      yxCM=cd[1];
      dd=cd[2];
    }
    else {
      yxCY=d.getFullYear();
      yxCM=d.getMonth();
      if (yxConf[4]==1) {
        dd=d.getDate();
      }
    }

    var calendar=yxCalHeader()+yxCalTitle(d)+yxCalBody(d,dd)+yxCalFooter();

    var cx=yxCurCal.dx, cy=yxCurCal.dy;
    if (yxCurCal.id=="" && yxCurCal.id2=="") {
      cx+=yxMX; cy+=yxMY;
    }
    else if (yxIsIE) {
      var l=yxLayers[yxCurCal.id];
      cx+=yxLeft(l); cy+=yxTop(l);
    }
    else if (yxIsN4) {
      var l=yxLayers[(yxCurCal.id2!="")?(yxCurCal.id2):(yxCurCal.id)];
      cx+=yxLeftN4(l); cy+=yxTopN4(l);
    }
    else {
      var l=yxLayers((yxIsK3 && yxCurCal.id2!="")?(yxCurCal.id2):(yxCurCal.id));
      cx+=yxLeft(l); cy+=yxTop(l);
    }

    if (yxIsIE) {
      yxLayers[yxCal].style.pixelTop=cy;
      yxLayers[yxCal].style.pixelLeft=cx;
      yxLayers[yxCal].innerHTML=calendar;

      yxLayers[yxCal].style.clip="rect(0px; "+yxLayers[yxCal].children[0].offsetWidth+"px; "+yxLayers[yxCal].children[0].offsetHeight+"px; 0px)";
      yxLayers[yxCal].style.visibility="visible";
    }
    else if (yxIsN4) {
      yxLayers[yxCal].top=cy;
      yxLayers[yxCal].left=cx;
      yxLayers[yxCal].document.open();
      yxLayers[yxCal].document.writeln(calendar);
      yxLayers[yxCal].document.close();
      yxLayers[yxCal].visibility="show";
    }
    else {
      yxLayers(yxCal).style.top=cy+"px";
      yxLayers(yxCal).style.left=cx+"px";
      yxLayers(yxCal).innerHTML=calendar;
      yxLayers(yxCal).style.visibility="visible";
    }
  }
  else {
    if (yxCurCal==null) {
      window.status="Calendar ["+name+"] not found.";
    }
    else if (!yxCurCal.form) {
      window.status="Form ["+yxCurCal.formName+"] not found.";
    }
    else if (!yxCurCal.form[yxCurCal.field]) {
      window.status="Form Field ["+yxCurCal.formName+"."+yxCurCal.field+"] not found.";
    }

    if (lastCal!=null) {
      yxCurCal=lastCal;
    }
  }
}; var showCalendar=yxShowCal;

function yxGetDD(n) {
  return ((n<10)?"0":"")+n;
}

function yxClearDate() {
  yxCurCal.form[yxCurCal.field].value="";

  if (yxConf[4]==0) {
    yxChangeCal(new Date(yxCY,yxCM,1));
  }

  yxHideCal();
}

function yxPickDate(d) {
  var date=yxConf[0];
  date=date.replace(/yyyy/i, yxCY);
  date=date.replace(/mm/i, yxGetDD(yxCM+1));
  date=date.replace(/MON/, yxMonths[yxCM].substring(0,3).toUpperCase());
  date=date.replace(/Mon/i, yxMonths[yxCM].substring(0,3));
  date=date.replace(/dd/i, yxGetDD(d));
  date=date.replace(/DAY/, yxDayName(yxCY,yxCM,d).toUpperCase());
  date=date.replace(/day/i, yxDayName(yxCY,yxCM,d));

  yxCurCal.form[yxCurCal.field].value=date;

  if (yxConf[4]==0) {
    yxChangeCal(new Date(yxCY,yxCM,1));
  }

  yxHideCal();
}

function yxClickIt(e) {
  if (yxIsIE || yxIsK3) {
    yxMX=event.clientX+(yxIsK3?0:window.document.body.scrollLeft);
    yxMY=event.clientY+(yxIsK3?0:window.document.body.scrollTop);
    event.cancelBubble=false;
  }
  else {
    yxMX=e.pageX; yxMY=e.pageY;
    document.routeEvent(e);
  }
}
// ------

// cal layer
if (yxIsN4) {
  document.writeln("<layer id='"+yxCal+"' z-index='2'>&nbsp;</layer>");
}
else {
  document.writeln("<div id='"+yxCal+"' style='position:absolute; z-index:2;'>&nbsp;</div>");
}

if (yxCalSafe) {
  if (yxIsN6 || yxIsN4) { document.captureEvents(Event.CLICK); }
  document.onclick=yxClickIt;
}
// ----

// user functions
function addCalendar(name, field, form, date, id, id2, dx, dy) {
  yxCals[yxCals.length]=new yxCalOBJ(name, field, form, date, id, id2, dx, dy);
}

function setFont(font, size) {
  if (font!="") { yxConf[5]=font; }
  if (size>0) {
    yxConf[6]=size;
    if (yxIsN4) { yxConf[6]+=2; }
  }
}

function setWidth(tWidth, tMode, dWidth, dDigits) {
  if (tWidth>0) { yxConf[7]=tWidth; }
  if (tMode==1 || tMode==2) { yxConf[8]=tMode; }
  if (dWidth>0) {
    yxConf[9]=dWidth;
    if (yxIsIE && yxIsMac) { yxConf[9]+=4; }
  }
  if (dDigits>0) { yxConf[10]=dDigits; }
}

function setColor(tColor, wColor, dColor, cdColor, odColor, bColor, fColor, bdColor) {
  if (tColor!="") { yxColors[0]=tColor; }
  if (wColor!="") { yxColors[2]=wColor; }
  if (dColor!="") { yxColors[4]=dColor; }
  if (cdColor!="") { yxColors[6]=cdColor; }
  if (odColor!="") { yxColors[8]=odColor; }
  if (bColor!="") { yxColors[10]=bColor; }
  if (fColor!="") { yxColors[11]=fColor; }
  if (bdColor!="") { yxColors[13]=bdColor; }
}

function setFontColor(tColorF, wColorF, dColorF, cdColorF, odColorF, fColorF) {
  if (tColorF!="") { yxColors[1]=tColorF; }
  if (wColorF!="") { yxColors[3]=wColorF; }
  if (dColorF!="") { yxColors[5]=dColorF; }
  if (cdColorF!="") { yxColors[7]=cdColorF; }
  if (odColorF!="") { yxColors[9]=odColorF; }
  if (fColorF!="") { yxColors[12]=fColorF; }
}

function setFormat(format) { yxConf[0]=format; }

function setWeekDay(wDay) {
  if (wDay==0 || wDay==1) { yxConf[1]=wDay; }
}

function setMonthTitles(jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec) {
  if (jan!="") { yxMonths[0]=jan; }
  if (feb!="") { yxMonths[1]=feb; }
  if (mar!="") { yxMonths[2]=mar; }
  if (apr!="") { yxMonths[3]=apr; }
  if (may!="") { yxMonths[4]=may; }
  if (jun!="") { yxMonths[5]=jun; }
  if (jul!="") { yxMonths[6]=jul; }
  if (aug!="") { yxMonths[7]=aug; }
  if (sep!="") { yxMonths[8]=sep; }
  if (oct!="") { yxMonths[9]=oct; }
  if (nov!="") { yxMonths[10]=nov; }
  if (dec!="") { yxMonths[11]=dec; }
}

function setDayTitles(sun, mon, tue, wed, thu, fri, sat) {
  if (sun!="") { yxDays[0]=sun; yxDays[7]=sun; }
  if (mon!="") { yxDays[1]=mon; }
  if (tue!="") { yxDays[2]=tue; }
  if (wed!="") { yxDays[3]=wed; }
  if (thu!="") { yxDays[4]=thu; }
  if (fri!="") { yxDays[5]=fri; }
  if (sat!="") { yxDays[6]=sat; }
}

function setLinkTitles(clearL, closeL) {
  if (clearL!="") { yxLinks[0]=clearL; }
  if (closeL!="") { yxLinks[1]=closeL; }
}

function switchLinks(mode) { yxConf[3]=mode; }

function setScrollTags(lOuter, rOuter, lInner, rInner) {
  if (lOuter!="") { yxTags[0]=lOuter; }
  if (rOuter!="") { yxTags[1]=rOuter; }
  if (lInner!="") { yxTags[2]=lInner; }
  if (rInner!="") { yxTags[3]=rInner; }
}

function switchTags(mode) { yxConf[2]=mode; }

function setCalendarMode(mode) { yxConf[4]=mode; }

function setRange(name, start, end) {
  var cal=yxFindCal(name);
  if (cal!=null) {
    cal.range=new Array(start, end);
  }
}

function enableRange(name, start, end) {
  var cal=yxFindCal(name);
  if (cal!=null) {
    cal.rangeOn[cal.rangeOn.length]=new Array(start, end);
  }
}

function disableRange(name, start, end) {
  var cal=yxFindCal(name);
  if (cal!=null) {
    cal.rangeOff[cal.rangeOff.length]=new Array(start, end);
  }
}

function enableDates(name, dates) {
  var cal=yxFindCal(name);
  if (cal!=null) {
    cal.datesOn+=dates+", ";
  }
}

function disableDates(name, dates) {
  var cal=yxFindCal(name);
  if (cal!=null) {
    cal.datesOff+=dates+", ";
  }
}

function setDays(name, sun, wk, sat) {
  var cal=yxFindCal(name);
  if (cal!=null) {
    cal.Sun=sun; cal.work=wk; cal.Sat=sat;
  }
}

function checkDate(name) {
  var thisCal=yxFindCal(name);

  if (thisCal!=null && thisCal.form!=null && thisCal.form[thisCal.field]) {
    var calRE=yxFormat();

    if (calRE.test(thisCal.form[thisCal.field].value)) {
      return 0;
    }
    else {
      return 1;
    }
  }
  else {
    return 2;
  }
}

function yxGetDate(d) {
  var date=yxConf[0];
  date=date.replace(/yyyy/i, d.getFullYear());
  date=date.replace(/mm/i, yxGetDD(d.getMonth()+1));
  date=date.replace(/MON/, yxMonths[d.getMonth()].substring(0,3).toUpperCase()); 
  date=date.replace(/Mon/i, yxMonths[d.getMonth()].substring(0,3)); 
  date=date.replace(/dd/i, yxGetDD(d.getDate()));

  return date;
}

function getCurrentDate() { return yxGetDate(new Date()); }

function compareDates(date1, date2) {
  var calRE=yxFormat();
  var d1, d2;

  if (calRE.test(date1)) {
    d1=getNumbers(date1);
  }
  else {
    d1=getNumbers(getCurrentDate());
  }

  if (calRE.test(date2)) {
    d2=getNumbers(date2);
  }
  else {
    d2=getNumbers(getCurrentDate());
  }

  var dStr1=d1[0]+""+d1[1]+""+d1[2];
  var dStr2=d2[0]+""+d2[1]+""+d2[2];

  if (dStr1==dStr2) {
    return 0;
  }
  else if (dStr1>dStr2) {
    return 1;
  }
  else {
    return -1;
  }
}

function getNumbers(date) {
  var calRE=yxFormat();
  var y, m, d;

  if (calRE.test(date)) {
    var yIdx=yxConf[0].search(/yyyy/i);
    var mIdx=yxConf[0].search(/mm/i);
    var m3Idx=yxConf[0].search(/mon/i);
    var dIdx=yxConf[0].search(/dd/i);

    y=date.substring(yIdx,yIdx+4);
    if (mIdx!=-1) {
      m=date.substring(mIdx,mIdx+2);
    }
    else {
      var mm=yxMonthFromName(date.substring(m3Idx,m3Idx+3))+1;
      m=(mm<10)?("0"+mm):(""+mm);
    }
    d=date.substring(dIdx,dIdx+2);

    return new Array(y,m,d);
  }
  else {
    return new Array("", "", "");
  }
}
// ------
